import java.util.Arrays;

/**
 * @USER: Administrator
 * @DATE: 2024/9/29 上午7:28
 * @VERSION: 1.0.0
 */
public class LC2558 {
    public long pickGifts(int[] gifts, int k) {
        long sum = 0;
        while (k>0){
            Arrays.sort(gifts);
            gifts[gifts.length-1] = (int) Math.sqrt(gifts[gifts.length-1]);
            k--;
        }

        for (int gift : gifts) {
            sum += gift;
        }
        return sum;
    }
}
